﻿/*
 * ©2009-2010 XELF
 * http://xelf.info
 */

using System;

#if XNA || WINDOWS_PHONE
using Microsoft.Xna.Framework;
#endif

namespace XELF.Framework {
#if XNA || WINDOWS_PHONE
	public static partial class MatrixHelper {
#else
	public partial struct Matrix {
#endif
		/// <summary>
		/// X軸周りの回転
		/// </summary>
		/// <param name="radians"></param>
		/// <returns></returns>
		public static Matrix CreateRotationX(float radians) {
			var c = MathHelper.Cos(radians);
			var s = MathHelper.Sin(radians);
			return new Matrix(
				+1, 0, 0, 0,
				 0, +c, +s, 0,
				 0, -s, +c, 0,
				 0, 0, 0, +1);
		}

		/// <summary>
		/// Y軸周りの回転
		/// </summary>
		/// <param name="radians"></param>
		/// <returns></returns>
		public static Matrix CreateRotationY(float radians) {
			var c = MathHelper.Cos(radians);
			var s = MathHelper.Sin(radians);
			return new Matrix(
				+c, 0, -s, 0,
				 0, +1, 0, 0,
				+s, 0, +c, 0,
				 0, 0, 0, +1);
		}

		/// <summary>
		/// Z軸周りの回転
		/// </summary>
		/// <param name="radians"></param>
		/// <returns></returns>
		public static Matrix CreateRotationZ(float radians) {
			var c = MathHelper.Cos(radians);
			var s = MathHelper.Sin(radians);
			return new Matrix(
				+c, +s, 0, 0,
				-s, +c, 0, 0,
				 0, 0, +1, 0,
				 0, 0, 0, +1);
		}
	}

}
